package com.heatup.apt.api.controller;

import java.util.Date;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import com.heatup.apt.api.service.CoachCommentService;
import com.heatup.apt.api.service.CourseService;
import com.heatup.apt.api.service.CourseSignService;
import com.heatup.apt.api.service.UserService;
import com.heatup.apt.common.util.*;
import com.heatup.apt.model.coach.CoachInfo;
import com.heatup.apt.model.course.CourseSign;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.heatup.apt.common.constants.ErrorCodeConstants;
import com.heatup.apt.model.api.ApiResultModel;
import com.heatup.apt.model.coach.CoachUserInfo;
import com.heatup.apt.model.course.CourseInfo;
import com.heatup.apt.model.user.UserInfo;

@RequestMapping(value = "/sign")
@Controller
public class CourseSignInOrOutController extends BaseController {
	public static final Logger logger = LoggerFactory.getLogger(CourseSignInOrOutController.class);

	@Autowired
    private CourseSignService courseSignService;
    
    @Autowired
    private UserService userService;
    
    @Autowired
	private CoachCommentService coachCommentService;
    
    @Autowired
    private CourseService courseService;
    
	@RequestMapping(value = "/getUserCourseList")
    @ResponseBody
    public String getUserCourseInfo(HttpServletRequest request) {
    	ApiResultModel<CoachUserInfo> apiResultModel = new ApiResultModel<CoachUserInfo>();
    	String callback = RequestTools.RequestString(request, "callback", "");
    	boolean isLogined = isLogined();
        if (!isLogined) {
            apiResultModel.setErrorCode(ErrorCodeConstants.Code.USER_NOT_LOGIN.getCode());
            apiResultModel.setMsg(ErrorCodeConstants.Code.USER_NOT_LOGIN.getMessage());
            return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
        } 
    	int userId = RequestTools.RequestInt(request, "userId", 0);
    	int courseId = RequestTools.RequestInt(request, "courseId", 0);
    	Integer orderId = RequestTools.RequestInt(request, "orderId", 0);
    	
    	CoachUserInfo coachModel = new CoachUserInfo();
    	//根据课程id查询课程详细信息
        CourseInfo ci = courseService.getCourseInfoById(courseId);
        if(ci == null){
        	 apiResultModel.setErrorCode(ErrorCodeConstants.Code.SECRET_ERROR_EXCEPTION.getCode());
             apiResultModel.setMsg("课程查询异常");
             return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
        }
        UserInfo userInfo = userService.getUserInfoById(userId);
        //签到未销课的课程
        List<Map<String, Object>> noSignList = courseSignService.queryUserCourseInfo(userId, courseId, 0, orderId);
        //已经销课的课程
        List<Map<String, Object>> coachList = courseSignService.queryUserCourseInfo(userId, courseId, 1, orderId);
    	if(orderId == null || orderId == 0) {
    		 apiResultModel.setErrorCode(ErrorCodeConstants.Code.COURSE_ORDER_ID_NULL.getCode());
             apiResultModel.setMsg(ErrorCodeConstants.Code.COURSE_ORDER_ID_NULL.getMessage());
             return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
    	}
    	Map<String, Object> oiMap= courseService.getPrice(orderId);
    	if(oiMap == null) {
   		 	apiResultModel.setErrorCode(ErrorCodeConstants.Code.COURSE_ORDER_ID_NULL.getCode());
            apiResultModel.setMsg(ErrorCodeConstants.Code.COURSE_ORDER_ID_NULL.getMessage());
            return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
    	}
    	coachModel.setAmount(oiMap.get("amount").toString());//实付金额
    	coachModel.setPrime_price(oiMap.get("prime_price").toString());
//        //如果 总共课时 不等于已上课时  就只能让用户先签到 再销课
//        if(noSignList != null && noSignList.size() < 1 && ci.getPeriods() != coachList.size()) {
//        	apiResultModel.setErrorCode(ErrorCodeConstants.Code.COURSE_ORDER_ID_NULL.getCode());
//            apiResultModel.setMsg("请先让学员签到！");
//            return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
//        }
        coachModel.setNoSignList(noSignList);
        coachModel.setCoachList(coachList);
        coachModel.setTotleCourse(ci.getPeriods());
        coachModel.setCourseName(ci.getTitle());
        coachModel.setHeadImg(userInfo.getHeadImg());
        coachModel.setMobile(userInfo.getMobile());
        coachModel.setNickName(userInfo.getNickName());
        coachModel.setLessCourse(ci.getPeriods() - coachList.size());
        apiResultModel.setData(coachModel);
        apiResultModel.setLogined(isLogined);
        return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
    }
	
    /**
	 * 销课
	 * <P>Author : lusa </P>      
	 * <P>Date : 2016年10月21日 </P>
	 *  num 课程顺序
	 *  id 签到ID
	 *  courseId 课程ID
	 *  storeId 门店ID
	 *  startTime 开始时间
	 *  closeTime 关闭时间
	 * @return
	 */
	@RequestMapping(value = "/close_course")
    @ResponseBody
	public String closeCourse(HttpServletRequest request) {

		ApiResultModel apiResultModel = new ApiResultModel(isLogined());
		String callback = RequestTools.RequestString(request, "callback", "");
		String storeIdTemp = RequestTools.RequestString(request, "storeId", "");
		String idTemp = RequestTools.RequestString(request, "id", "");//对应的签到id
		String closeTimeTemp = RequestTools.RequestString(request, "closeTime", "");
		String comment = RequestTools.RequestString(request, "comment", "");
		String serviceIds = RequestTools.RequestString(request, "serviceIds", "");
		String startTimeTemp = RequestTools.RequestString(request, "startTime", "");
		String num = RequestTools.RequestString(request, "num", "");
		String courseId = RequestTools.RequestString(request, "courseId", "");
		String userId = RequestTools.RequestString(request, "userId", "");//用户id
		String orderId = RequestTools.RequestString(request, "orderId", "");
		Integer courseIdInt = StringUtils.isBlank(courseId) ? 0 : Integer.parseInt(courseId);
		Integer userIdInt = StringUtils.isBlank(userId) ? 0 : Integer.parseInt(userId);
		//教练评论
		if(StringUtils.isNotBlank(comment) || StringUtils.isNotBlank(serviceIds)) {
			coachCommentService.insertCommentInfo(comment, userIdInt, courseIdInt, serviceIds, getUserId());
		}
		Date closeDate = null;
		Date startTime = null;
		try {
			startTime = DateUtils.toDateTime(startTimeTemp);
			closeDate = DateUtils.toDateTime(closeTimeTemp);
		} catch (Exception e) {
			e.printStackTrace();
			logger.error( e.toString() + e.getCause());
		}
        if (storeIdTemp != null && idTemp != null) {
//        	updateCancelCourse(String num, String id, String courseId,
//        			String storeId,String orderId,String startTime, String closeTime,Integer userId)
            int count = 0;
			try {
				count = courseSignService.updateCancelCourse(num, idTemp,courseId, storeIdTemp,orderId, startTimeTemp, closeTimeTemp, getUserId());
			} catch (Exception e) {
				logger.error(e.getMessage() + e.toString());
			}
            if (count > 0) {
                apiResultModel.setMsg("销课成功！");
                apiResultModel.setRet(ApiResultModel.RET_SUCCESS);
            } else {
                apiResultModel.setMsg("销课失败！");
                apiResultModel.setRet(ApiResultModel.RET_ERROR);
            }
        } else {
            apiResultModel.setMsg("入参数据异常！");
            apiResultModel.setRet(ApiResultModel.RET_ERROR);
        }

        return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
	}
	
	
	/**
	 * 下载图片
	 */
	@RequestMapping(value = "/down_img")
    @ResponseBody
	public String downLoadPic(HttpServletRequest request) {
		String serviceIds = RequestTools.RequestString(request, "serviceIds", "");
		logger.info("serviceIds value is : " +serviceIds);
		String callback = RequestTools.RequestString(request, "callback", "");
		List<String> list = coachCommentService.getImgFromWx(serviceIds);
		logger.info("上传图片地址：" + list.toString());
		ApiResultModel apiResultModel = new ApiResultModel(isLogined());
		apiResultModel.setData(list);
		return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
	}

	/**
	 *@Author: timo
	 *@Date: 2018/3/27 11:08
	 *@Description:
	 * 创建私教课程日程
	 * 1.添加体测日程
	 * 2.添加体验日程
	 * 3.添加私教日程
	 */
	@ResponseBody
	@RequestMapping("/save_course_sign")
	public String saveCourseSign(HttpServletRequest request, @RequestBody Map<String,Object> paramMap){
		String callback = RequestTools.RequestString(request, "callback", "");
		UserInfo userInfo = this.getUserInfo();
		ApiResultModel apiResultModel = new ApiResultModel(isLogined());

		try {

			CourseSign courseSign = new CourseSign();

			String startTime = (String) paramMap.get("startTime");
			String endTime = (String) paramMap.get("endTime");
			if(StringUtil.isNotEmpty(startTime))
				courseSign.setStartTime(DateUtils.toDate((String) paramMap.get("startTime"),DateUtils.datePatternAllHH));
			if (StringUtil.isNotEmpty(endTime))
				courseSign.setEndTime(DateUtils.toDate((String) paramMap.get("endTime"),DateUtils.datePatternAllHH));

			courseSign.setOrderId((Integer) paramMap.get("orderId"));
			courseSign.setRemark((String) paramMap.get("remark"));
			Object courseSignIdObj = paramMap.get("courseSignId");

			if(StringUtil.isNotEmpty(courseSignIdObj)){
				courseSign.setId((Integer) paramMap.get("courseSignId"));
			}

			courseSign.setSignType((Integer) paramMap.get("signType"));

			apiResultModel = courseSignService.saveCourseSign(userInfo, courseSign);
		}catch (Exception e){
			logger.error("saveCourseSign| error:"+e.toString()+e.getCause(),e);
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getCode());
		}
		return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
	}

	/**
	 *@Author: timo
	 *@Date: 2018/3/28 21:28
	 *@Description:
	 * 查询教练的日程列表
	 *
	 */
	@ResponseBody
	@RequestMapping("/get_coach_course_sign_list")
	public String getCoachCourseSignList(HttpServletRequest request){
		String callback = RequestTools.RequestString(request, "callback", "");
		String startTime = RequestTools.RequestString(request, "startTime", "");
		Integer sonCoachId = RequestTools.RequestInt(request, "sonCoachId",0);
		UserInfo userInfo = this.getUserInfo();
		ApiResultModel apiResultModel = new ApiResultModel(isLogined());

		// 用户未登录
		if(userInfo == null){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.USER_NOT_LOGIN.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.USER_NOT_FIND.getCode());
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		// 没有绑定手机号码
		if(StringUtil.isEmpty(userInfo.getMobile())){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.COACH_MOBILE_NOT_BIND.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.COACH_MOBILE_NOT_BIND.getCode());
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		// 查询日期不能为空
		if(StringUtil.isEmpty(startTime)){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg("查询日期不能为空");
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		// 教练不存在
		CoachInfo coachInfo = this.getCoachInfo();
		if(coachInfo == null){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.COACH_NOT_MATCH.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.COACH_NOT_MATCH.getCode());
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		// 不是主教练 不能查看别人的日程
		if(sonCoachId > 0 && coachInfo.getIsChiefCoach() != 1){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg("您没有权限");
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}


		try {
			Date queryDate = DateUtils.toDate(startTime);
			apiResultModel = courseSignService.queryCoachCourseSignList(userInfo,queryDate,sonCoachId, coachInfo.getIsChiefCoach());
		}catch (Exception e){
			logger.error("getCoachCourseSignList | error:"+e.toString()+e.getCause(),e);
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getCode());
		}
		return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
	}


	/**
	 *@Author: timo
	 *@Date: 2018/3/28 22:02
	 *@Description:
	 * 查看日程详情
	 *
	 */
	@ResponseBody
	@RequestMapping("/get_course_sign_order_detail")
	public String getCourseSignOrderDetail(HttpServletRequest request){
		String callback = RequestTools.RequestString(request, "callback", "");
		Integer courseSignId = RequestTools.RequestInt(request,"courseSignId",0);
		Integer orderType = RequestTools.RequestInt(request, "orderType",0);

		UserInfo userInfo = this.getUserInfo();
		ApiResultModel apiResultModel = new ApiResultModel(isLogined());

		// 用户未登录
		if(userInfo == null){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.USER_NOT_LOGIN.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.USER_NOT_FIND.getCode());
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		// 没有绑定手机号码
		if(StringUtil.isEmpty(userInfo.getMobile())){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.COACH_MOBILE_NOT_BIND.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.COACH_MOBILE_NOT_BIND.getCode());
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		if(courseSignId == null || courseSignId <= 0){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg("日程ID不能为空！");
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		try {
			apiResultModel = courseSignService.queryCourseSignDetail(userInfo,courseSignId,orderType);
		}catch (Exception e){
			logger.error("getCourseSignOrderDetail | error:"+e.toString()+e.getCause(),e);
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getCode());
		}
		return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
	}


	/**
	 *@Author: timo
	 *@Date: 2018/3/29 16:50
	 *@Description:
	 * 取消日程
	 * 1.体测体验课的取消日程 是直接删除掉日程
	 * 2.私教的取消日程是将该日程的教练置为null
	 *
	 */
	@ResponseBody
	@RequestMapping("/cancel_course_sign")
	public String cancelCourseSign(HttpServletRequest request ){
		String callback = RequestTools.RequestString(request, "callback", "");
		Integer courseSignId = RequestTools.RequestInt(request, "courseSignId", 0);
		Integer orderType = RequestTools.RequestInt(request, "orderType", 0);
		UserInfo userInfo = this.getUserInfo();
		ApiResultModel apiResultModel = new ApiResultModel(isLogined());

		// 用户未登录
		if(userInfo == null){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.USER_NOT_LOGIN.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.USER_NOT_FIND.getCode());
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		// 没有绑定手机号码
		if(StringUtil.isEmpty(userInfo.getMobile())){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.COACH_MOBILE_NOT_BIND.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.COACH_MOBILE_NOT_BIND.getCode());
			return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
		}

		try {
			apiResultModel = courseSignService.cancelCourseSign(userInfo,courseSignId,orderType,null);
		}catch (Exception e){
			logger.error("cancelCourseSign| error:"+e.toString()+e.getCause(),e);
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getCode());
		}
		return ResponseTools.CallBackResultJsonP(JsonUtils.obj2Json(apiResultModel), callback);
	}

	@ResponseBody
	@RequestMapping("/get_coach_note_list")
	public String getCoachNoteList(HttpServletRequest request){
		String callback = RequestTools.RequestString(request,"callback","");
		Integer pageIndex = RequestTools.RequestInt(request,"pageIndex",1);
		Integer pageSize = RequestTools.RequestInt(request, "pageSize",10);
		UserInfo userInfo = this.getUserInfo();
		ApiResultModel<Object> apiResultModel = new ApiResultModel<>();
		if (userInfo == null){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.USER_NOT_LOGIN.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.USER_NOT_LOGIN.getCode());
			return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);

		}

		try {
			apiResultModel = courseSignService.queryCoachNoteList(userInfo,pageIndex,pageSize);
		}catch (Exception e){
			logger.error("getCoachNoteList| error:"+e.toString()+e.getCause(),e);
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getCode());
		}
		return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);
	}

	/**
	 *@Author: timo
	 *@Date: 2018/3/30 18:46
	 *@Description:
	 * 删除教练备忘录
	 *
	 */
	@ResponseBody
	@RequestMapping("/del_coach_note")
	public String delCoachNote(HttpServletRequest request){
		String callback = RequestTools.RequestString(request,"callback","");
		Integer id = RequestTools.RequestInt(request, "id",0);
		UserInfo userInfo = this.getUserInfo();
		ApiResultModel<Object> apiResultModel = new ApiResultModel<>();
		if (userInfo == null){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.USER_NOT_LOGIN.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.USER_NOT_LOGIN.getCode());
			return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);

		}
		CoachInfo coachInfo = getCoachInfo();
		if (coachInfo == null) {
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.COACH_NOT_MATCH.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.COACH_NOT_MATCH.getCode());
			return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);
		}
		try {
			apiResultModel = courseSignService.delCourseSign(userInfo,coachInfo,id);
		}catch (Exception e){
			logger.error("getCoachNoteList| error:"+e.toString()+e.getCause(),e);
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getCode());
		}
		return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);
	}

	/**
	 *@Author: timo
	 *@Date: 2018/4/4 10:21
	 *@Description:
	 * 查询私教的备忘录详情
	 *
	 */
	@ResponseBody
	@RequestMapping("/get_coach_note_detail")
	public String getCaochNoteDetail(HttpServletRequest request){
		String callback = RequestTools.RequestString(request,"callback","");
		Integer id = RequestTools.RequestInt(request, "id",0);
		UserInfo userInfo = this.getUserInfo();
		ApiResultModel<Object> apiResultModel = new ApiResultModel<>();
		if (userInfo == null){
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.USER_NOT_LOGIN.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.USER_NOT_LOGIN.getCode());
			return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);

		}

		CoachInfo coachInfo = getCoachInfo();
		if (coachInfo == null) {
			apiResultModel.setRet(apiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.COACH_NOT_MATCH.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.COACH_NOT_MATCH.getCode());
			return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);
		}

		try {
			apiResultModel = courseSignService.queryCoachNoteDetail(coachInfo,id);
		}catch (Exception e){
			logger.error("getCaochNoteDetail| error:"+e.toString()+e.getCause(),e);
			apiResultModel.setRet(ApiResultModel.RET_ERROR);
			apiResultModel.setMsg(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getMessage());
			apiResultModel.setErrorCode(ErrorCodeConstants.Code.SYSTEM_ERROR_EXCEPTION.getCode());
		}
		return ResponseTools.CallBackResultJsonP(JsonTools.jsonSer(apiResultModel),callback);
	}
	
}
